<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../css/monitor.css">
		<!--标准mui.css-->
		<link rel="stylesheet" href="../../css/mui.css">
		<link rel="stylesheet" href="../../css/style.css">
		<link rel="stylesheet" href="../../src/style.css">
		<link rel="stylesheet" href="../../src/iconfont/iconfont.css">
		<link rel="stylesheet" href="../../css/video-js.min.css" />

		<!--App自定义的css-->
		<!--<link rel="stylesheet" type="text/css" href="../css/app.css"/>-->
		<style>

		</style>
	</head>

	<body>
		<div class="monitoradvert"><img src="../../src/img/videoImg.png"></div> 
		

		<div id="monitor">
			<div class="newVideoList">
				<ul v-for="item in items">
					<div class="titles">
						<p class="name" style="display: inline-block;">{{item.institution_name}}</p><span class="addrs" style="padding-left: 10px;font-size: 14px;">开放时间: 7:30-18:00(周六周天不开放)</span>
						<span class="addrs" style="display: block;">{{item.institution_address}}</span>
						<!-- <h1>+{{item.monitors.length}}</h1> -->
					</div>
					<li v-for="i in item.monitors" @tap="open_detail(i)"> 
						<div style="position: absolute;">
							<img :src="i.img" />
						</div>
						<div>
							<span>{{i.monitor_name}}</span>
							<span>-{{item.institution_name}}</span>
							<span>{{i.monitor_time}}</span>
							<span class="iconfont icon-video_fill_light"></span>
						</div>
					</li>
				</ul>
			</div>
		</div>

	</body>
	<script src="../../js/video.min.js"></script>
	<script src="../../js/jquery-1.11.3.js"></script>
	<script src="../../js/ezuikit.js"></script>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/vue.min.js"></script>
	<script src="../../js/app.js"></script>

	<script>
		
	
		
		mui.init({
			swipeBack: true, //启用右滑关闭功能
		});
		
		mui.plusReady(function() {
		
			var myPlayer = document.getElementById('myPlayer')
			/*mui.post("http://api.avatardata.cn/BeijingTime/LookUp", {
            key:'fec5548934d84f3087b372a6998a9c7b',
            
        }, function(data) {
            alert(JSON.stringify(data)) 
        }, 'json');*/
			

			var detailPage = null;
			var state = app.getState();
			uid = state.userid;
			memberToken = state.memberToken;
			var childid = state.childid
			var vip = state.vip;
			mui.post(Apiurl + 'index/monitor', {
				uid: uid,
				memberToken: memberToken,
				child_id: childid
			}, function(data) {
				console.log(data)
				console.log(JSON.stringify(data));
				if(data.status) {
					monitor.items = [];
				} else { 
					monitor.items = data;
				}
			}, 'json');
			
			/*var backButtonPress = 0;
			mui.back = function(event) {
				//console.log(plus.webview.currentWebview().id);   
				backButtonPress++;
				if(backButtonPress > 1) {
					plus.runtime.quit();
				} else {
					plus.nativeUI.toast('再按一次退出应用');
				}
				setTimeout(function() {
					backButtonPress = 0;
				}, 1000);
				return false;
			};*/
		});
		var time_range = function(beginTime, endTime) {
				var strb = beginTime.split(":");
				if(strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if(stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if(n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {
					return true;
				} else {
					return false;
				}
			}
		function judedweek() {
				var nowdate = new Date();
				var week = nowdate.getDay()
				if(week == 6 || week == 7) {
					return false;
				} else {
					return true;
				}

			}
		function fullScreen(element) {  
  if(element.requestFullScreen) {  
    element.requestFullScreen();  
  } else if(element.webkitRequestFullScreen ) {  
    element.webkitRequestFullScreen();  
  } else if(element.mozRequestFullScreen) {  
    element.mozRequestFullScreen();  
  }  
}  
		var monitor = new Vue({
				el: '#monitor',
				data: {
					items: []
				},
				mounted(){
					
				},
				methods: {
					open_detail: function(i) { 
						
						if(time_range("7:30", "18:00") && judedweek()) {
							mui.post(Apiurl + 'index/member_info', {
								uid: uid,
								memberToken: memberToken
							}, function(data) {  
								
								if(data.vip == 0) {
									mui.openWindow({
										url: '/pages/pcenter/charge/charge.html',
										id: 'charge',
										styles: {
											"render": "always",
											"popGesture": "hide",
											"bounce": "vertical",
											"bounceBackground": "#efeff4",
											cachemode: "noCache",
											"titleNView": titleNView = { //详情页原生导航配置
												autoBackButton: true, //自动绘制返回箭头
												backgroundColor: '#fff', //导航栏背景色
												titleText: i.monitor_name, //导航栏标题
												titleColor: '#000', //文字颜色
												//coverage:"120px",
												//type: 'transparent', //透明渐变样式
												splitLine: { //底部分割线
													color: '#dfdfdf'
												}
											}
										}
									});
								} else if(data.vip == 1) {
									 //e.target.requestFullScreen()
									mui.openWindow({
										url: 'detial.html',
										id: 'monitor_detial', 
										//createNew: true,
										extras: {
											videourl: i.monitor_http,
											posterurl: i.img,
											title: i.monitor_name 
										},
										styles: {
											"render": "always",
											"popGesture": "hide",
											"bounce": "vertical",
											"bounceBackground": "#efeff4",
											'cachemode': "noCache",
											"titleNView": titleNView = { //详情页原生导航配置
												autoBackButton: true, //自动绘制返回箭头
												backgroundColor: '#fff', //导航栏背景色
												titleText: i.monitor_name, //导航栏标题
												titleColor: '#000', //文字颜色
												//coverage:"120px",
												//type: 'transparent', //透明渐变样式
												splitLine: { //底部分割线
													color: '#dfdfdf'
												}
											}
										}
									});
								}
							}, "json")
						} else {
							mui.toast('未到开放时间，敬请谅解')
						}

						/*if(vip==0){
							mui.openWindow({
							url: '/pages/pcenter/charge/charge.html',
							id: 'charge',
							styles: {
								"render": "always",
								"popGesture": "hide",
								"bounce": "vertical",
								"bounceBackground": "#efeff4",
								cachemode: "noCache",   
								"titleNView": titleNView = { //详情页原生导航配置
									autoBackButton: true, //自动绘制返回箭头
									backgroundColor: '#25aae3', //导航栏背景色
									titleText: i.monitor_name, //导航栏标题
									titleColor: '#F7F7F7', //文字颜色
									//coverage:"120px",
									//type: 'transparent', //透明渐变样式
									splitLine: { //底部分割线
										color: '#cccccc'
									}
								}
							}
							});
						}else{
							mui.openWindow({
							url: 'detial.html',
							id: 'monitor_detial',
							//createNew: true,
							extras: {
								videourl: i.monitor_http,
								posterurl: i.img,
								title:i.monitor_name
							},
							styles: {
								"render": "always",
								"popGesture": "hide",
								"bounce": "vertical",
								"bounceBackground": "#efeff4",
								'cachemode': "noCache", 
								"titleNView": titleNView = { //详情页原生导航配置
									autoBackButton: true, //自动绘制返回箭头
									backgroundColor: '#25aae3', //导航栏背景色
									titleText: i.monitor_name, //导航栏标题
									titleColor: '#F7F7F7', //文字颜色
									//coverage:"120px",
									//type: 'transparent', //透明渐变样式
									splitLine: { //底部分割线
										color: '#cccccc'
									}
								}
							}
							});
						}*/

					}
				}
			});
		window.addEventListener("pageflowrefresh", function(e) {
			location.reload();
		});
		//切换孩子
		window.addEventListener('changeChild', function(event) {
			window.location.reload()
		});
	</script>

</html>